/*
 * Middleware
 * Copyright (C) 2010/11
 * Riccardo Pulvirenti, Giuseppe Ravidà, Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: tqueue_proxy_factory.cpp
 */

#include "tqueue_proxy_factory.hpp"

using namespace middleware;

//-----------------------------------------------------------------------------
// Constructors and destructor
/* Default constructor */
TQueueProxyFactory::TQueueProxyFactory(Worker* ptrtoworker) {
	this->_proxy = 0;
	this->_ptrto_worker = ptrtoworker;
}
/* Destructor */
TQueueProxyFactory::~TQueueProxyFactory() {
	if (this->_proxy != 0) delete this->_proxy; /* Safe deletion */
}
//-----------------------------------------------------------------------------
// Public members
/* Building and returning proxy */
TQueueManagerProxy* TQueueProxyFactory::getProxy() {
	if (this->_proxy != 0) delete this->_proxy; /* Clear first */
	TProxyConfig proxyconf;
	proxyconf.ptrto_worker = this->_ptrto_worker;
	this->_proxy = new TQueueManagerProxy(proxyconf); /* Dynamic alloc */
	return this->_proxy;
}
